package com.wb.iec104.analysis;

import java.util.ArrayList;
import java.util.List;

public class ASDUData {
    private int apduLength;
    private int type;
    private String reason;

    private List<Node> messageList =new ArrayList<Node>();

    public ASDUData buildApduLength(int apduLength){
        this.apduLength=apduLength;
        return this;
    }

    public ASDUData buildType(int type){
        this.type=type;
        return this;
    }

    public ASDUData buildReason(String reason){
        this.reason=reason;
        return this;
    }

    public int getApduLength() {
        return apduLength;
    }

    public void setApduLength(int apduLength) {
        this.apduLength = apduLength;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public List<Node> getMessageList() {
        return messageList;
    }

    public void setMessageList(List<Node> messageList) {
        this.messageList = messageList;
    }

    /**
     *
     * @param addr 信息体地址
     * @param floadData 浮点数
     * @param qds 品质描述 0 1
     * @return
     */
    public ASDUData buildList(String addr, String floadData,String qds){
        Node node = new Node(addr, Float.parseFloat(floadData) ,qds);
        messageList.add(node);
        return this;
    }

    /**
     *
     * @param addr 信息体地址
     * @param floadData 浮点数
     * @param qds 品质描述 0 1
     * @param time 时间
     * @return
     */
    public ASDUData buildList(String addr, String floadData,String qds,String time){
        Node node = new Node(addr, Float.parseFloat(floadData) ,qds,time);
        messageList.add(node);
        return this;
    }

    /**
     *
     * @param addr 信息体地址
     * @param qds 品质描述 0 1
     * @return
     */
    public ASDUData buildList(String addr, String qds){
        Node node = new Node(addr, qds);
        messageList.add(node);
        return this;
    }

    public ASDUData buildAddr(String addr){
        Node node = new Node(addr);
        messageList.add(node);
        return this;
    }


    public static class Node {
        //信息提地址
         private String addr;
         //浮点数  //
         private float floatData;
        //品质
        private String qds;

         private String time;

        public Node(String addr, float floatData,String qds) {
            this.addr = addr;
            this.floatData = floatData;
            this.qds=qds;
        }

        public Node(String addr, float floatData,String qds,String time) {
            this.addr = addr;
            this.floatData = floatData;
            this.qds=qds;
            this.time=time;
        }

        public Node(String addr, String qds) {
            this.addr = addr;
            this.qds=qds;
        }

        public Node(String addr) {
            this.addr=addr;
        }

        @Override
        public String toString() {
            return "Node{" +
                    "addr='" + addr + '\'' +
                    ", floatData=" + floatData +
                    ", qds='" + qds + '\'' +
                    ", time='" + time + '\'' +
                    '}';
        }

        public String getAddr() {
            return addr;
        }

        public void setAddr(String addr) {
            this.addr = addr;
        }

        public float getFloatData() {
            return floatData;
        }

        public void setFloatData(float floatData) {
            this.floatData = floatData;
        }

        public String getQds() {
            return qds;
        }

        public void setQds(String qds) {
            this.qds = qds;
        }

        public String getTime() {
            return time;
        }

        public void setTime(String time) {
            this.time = time;
        }
    }

    @Override
    public String toString() {
        return "ASDUData{" +
                "apduLength=" + apduLength +
                ", type='" + type + '\'' +
                ", reason='" + reason + '\'' +
                ", messageList=" + messageList +
                '}';
    }
}
